function [Gram,RHS] = DLS_GramBuilder(M,Order)
%Build Gram matrix and RHS
deg=Order+1;
Gram =zeros(deg,deg);
RHS = zeros(deg,1);
for i=0:deg-1 
   for j=0:deg-1
      Gram(i+1,j+1)=sum((M(:,1).^(i+j)).*weightfunc(M(:,1)));
   end
end
for i=1:deg 
   RHS(i,1) = ((M(:,1).^(i-1)).*weightfunc(M(:,1)))'*(M(:,2));
end
end

function y = weightfunc(x)
y=ones(length(x),1);
end



